package com.qiandw.myblog.service.impl;

import com.qiandw.myblog.entity.Category;
import com.qiandw.myblog.mapper.CategoryMapper;
import com.qiandw.myblog.service.CategoryService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * 分类服务实现类
 *
 * @author KG
 */
@Service
public class CategoryServiceImpl extends BaseServiceImpl<CategoryMapper, Category> implements CategoryService {

    @Override
    public void join(Map<String, Object> map, String field) {
        if (map == null || map.get(field) == null) {
            return;
        }
        Map<String, Object> joinColumns = new HashMap<>();
        //字段的值
        String linkfieldValue = map.get(field).toString();
        Category category = this.getById(linkfieldValue);

        joinColumns.put("id", category.getId());
        joinColumns.put("name", category.getName());
        joinColumns.put("icon", category.getIcon());
        map.put("category", joinColumns);
    }
}
